import time
# 博客编辑页面_写博客
from selenium.webdriver.common.by import By
from common.Ultils import BlogDriver

class BlogEdit:
    url=""
    driver=""
    def __init__(self):
        self.url="http://8.137.19.140:9090/blog_edit.html"
        self.driver=BlogDriver.driver
        self.driver.get(self.url)

    def EditSucTestByLogin(self):
        #键入标题内容
        self.driver.find_element(By.CSS_SELECTOR,"#title").send_keys("自动化测试博客系统")
        time.sleep(2)
        #功能栏
        # self.driver.find_element(By.CSS_SELECTOR,"#editor > div.editormd-toolbar > div")
        # print("已完成对功能栏的定位")
        #对于功能栏H1功能的测试——可以进行点击
        self.driver.find_element(By.CSS_SELECTOR,"#editor > div.editormd-toolbar > div > ul > li:nth-child(13) > a > i").click()
        # 截屏操作
        BlogDriver.getScreeShot()
        #点击“发布博客按钮”
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        actual=self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(550) > div.title").text
        assert actual == "自动化测试博客系统"
